<%@ page import="mybean.data.Example7_2_Bean" %>
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=utf-8" %>
<%
    Example7_2_Bean resultBean=null;
    try{  resultBean=(Example7_2_Bean)request.getAttribute("resultBean");
        if(resultBean==null){
            resultBean=new Example7_2_Bean();
            request.setAttribute("resultBean",resultBean);
        }
    }
    catch(Exception exp){
        resultBean=new Example7_2_Bean();
        request.setAttribute("resultBean",resultBean);
    }
    try{  Class.forName("com.mysql.jdbc.Driver");

    }
    catch(Exception e){}

    Connection con;
    Statement sql;
    ResultSet rs;
    try{
        String uri="jdbc:mysql://127.0.0.1/chu_data";
        con= DriverManager.getConnection(uri,"root","");
        sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        String condition ="SELECT * FROM paragraph";
        rs=sql.executeQuery(condition);
        ResultSetMetaData metaData = rs.getMetaData();
        int columnCount = metaData.getColumnCount();
        String []columnName = new String[columnCount];
        for(int i=0;i<columnName.length;i++) {
            columnName[i] = metaData.getColumnName(i+1);
        }
        resultBean.setColumnName(columnName);
        rs.last();
        int rowNumber=rs.getRow();
        String [][] tableRecord=resultBean.getTableRecord();
        tableRecord = new String[rowNumber][columnCount];
        rs.beforeFirst();
        int i=0;
        while(rs.next()){
            for(int k=0;k<columnCount;k++)
                tableRecord[i][k] = rs.getString(k+1);
            i++;
        }
        resultBean.setTableRecord(tableRecord);
        con.close();
        /*RequestDispatcher dispatcher=
                request.getRequestDispatcher("index.jsp");
        dispatcher.forward(request,response);*/
    }
    catch(SQLException e){
        System.out.println(e);
    }
%>
<html>
<!--头部信息-->
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta property="wb:webmaster" content="3aababe5ed22e23c" />
    <meta name="referrer" content="always" />
    <title>Jsp期末作业</title>
    <link href="css/index_modex.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="js/index_modex.js" charset="gbk"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/echarts.min.js" charset="utf8"></script>

</head>
<body class="layout">
<!--头部开始-->
<div class="top">
    <!--导航开始-->
    <div class="dr">
        <!--导航栏中部-->
        <div class="dr-center">
            <li><a href="#">首页</a></li>
            <li><a href="#">提供商</a></li>
            <li><a href="#">目录</a></li>
            <li><a href="#">需求</a></li>
            <li><a href="#">常见问题</a></li>
            <li><a href="#">联系我们</a></li>
        </div>
        <!--注册登陆按钮-->
        <div class="dr-right">
            <li><a href="#" data-toggle="modal" data-target="#register" class="dr-a">注册</a></li>
            <p>|</p>
            <li><a href="#" data-toggle="modal" data-target="#login" class="dr-a">登陆</a></li>
            <!-- 注册登陆弹出窗口开始 -->
            <!--注册窗口-->
            <div id="register" class="modal fade" tabindex="-1">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <button class="close" data-dismiss="modal">
                                <span>&times;</span>
                            </button>
                        </div>
                        <div class="modal-title">
                            <h1 class="text-center">注册</h1>
                        </div>
                        <div class="modal-body">
                            <form class="form-group" action="insertServlet" method="post" onsubmit="return checkForm0(this);">
                                <div class="form-group">
                                    <label for="">用户名</label>
                                    <input class="form-control" type=text name="name"  placeholder="6-15位字母或数字">
                                </div>
                                <div class="form-group">
                                    <label for="">密码</label>
                                    <input class="form-control" type="password" name="password" placeholder="至少6位字母或数字">
                                </div>
                                <div class="form-group">
                                    <label for="">再次输入密码</label>
                                    <input class="form-control" type="password"  placeholder="至少6位字母或数字">
                                </div>
                                <div class="form-group">
                                    <label for="">邮箱</label>
                                    <input class="form-control" type="email" name="email" placeholder="例如:123@123.com">
                                </div>
                                <div class="text-right">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                    <button class="btn btn-danger" data-dismiss="modal">取消</button>
                                </div>
                                <a href="" data-toggle="modal" data-dismiss="modal" data-target="#login">已有账号？点我登录</a>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 登录窗口 -->
            <div id="login" class="modal fade">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-body">
                            <button class="close" data-dismiss="modal">
                                <span>&times;</span>
                            </button>
                        </div>
                        <div class="modal-title">
                            <h1 class="text-center">登录</h1>
                        </div>
                        <div class="modal-body">
                            <form class="form-group" action="selectServlet" method="post" onsubmit="return checkForm(this);">

                                <div class="form-group">
                                    <label for="">用户名</label>
                                    <input class="form-control" type="text" name="name" placeholder="">
                                </div>
                                <div class="form-group">
                                    <label for="">密码</label>
                                    <input class="form-control" type="password" name="pass" placeholder="">
                                </div>
                                <div class="text-right">
                                    <button class="btn btn-primary" type="submit">登录</button>
                                    <button class="btn btn-danger" data-dismiss="modal">取消</button>
                                </div>
                                <a href="" data-toggle="modal" data-dismiss="modal" data-target="#register">还没有账号？点我注册</a>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 注册登陆弹出窗口结束 -->

        </div>
    </div>
    <!--导航结束-->
</div>
<div class="clear"></div>

<!--头部结束，中部开始-->
<div class="center">
    <div id="main" class="table"></div>
    <!--关于我们-->
    <div class="about-us">
        <div class="about-us-bt">
            <p class="p1">数海</p>
            <p class="p2">科技</p>
        </div>
        <!--清除浮动-->
        <div class="clear"></div>

        <div class="about-us-link">
            <p class="p3">关于我们</p>
        </div>
        <div class="about-us-wbk">
            <%  String [][] record = resultBean.getTableRecord(); %>
            <br>
            <p><%= record[0][1] %></p>
            <p><%= record[1][1] %></p>
            <p><%= record[2][1] %></p>
            <p><%= record[3][1] %></p>
            <p><%= record[4][1] %></p>
            <p><%= record[5][1] %></p>
            <a href="#" class="a1">READ MORE</a>
        </div>

    </div>
    <!--清除浮动-->
    <div class="clear"></div>
    <!--新闻动态-->
    <div class="new">
        <div class="xwdt"></div>
        <div class="nr">
            <!--轮播图-->
            <div class="lbt">
                <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                    <!-- Indicators -->
                    <ol class="carousel-indicators">
                        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                        <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                        <li data-target="#carousel-example-generic" data-slide-to="2"></li>
                    </ol>

                    <!-- Wrapper for slides -->
                    <div class="carousel-inner" role="listbox">
                        <div class="item active">
                            <img src="img/center_lbt1.png" alt="...">
                            <div class="carousel-caption">
                            </div>
                        </div>
                        <div class="item">
                            <img src="img/center_lbt1.png" alt="...">
                            <div class="carousel-caption">
                            </div>
                        </div>
                        <div class="item">
                            <img src="img/center_lbt1.png" alt="...">
                            <div class="carousel-caption">
                            </div>
                        </div>
                    </div>

                    <!-- Controls -->
                    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                        <span class="sr-only">Next</span>
                    </a>
                </div>
            </div>
            <div class="new-nr">
                <div class="nr1">
                    <div class="bt">
                        <p class="btsz">1</p>
                    </div>
                    <div class="xwnr xwnrss">
                        <li class="l1">未来战争：用大数据夺取制信息权。</li>
                        <li class="l2">2018.04.21</li>
                        <li class="l3"><p><%= record[6][1] %></p></li>
                    </div>
                </div>
                <div class="nr2">
                    <div class="bt">
                        <p class="btsz">2</p>
                    </div>
                    <div class="xwnr">
                        <li class="l1">未来战争：用大数据夺取制信息权。</li>
                        <li class="l2">2018.04.21</li>
                        <li class="l3"><p><%= record[7][1] %></p></li>
                    </div>
                </div>
                <div class="nr1">
                    <div class="bt">
                        <p class="btsz">3</p>
                    </div>
                    <div class="xwnr">
                        <li class="l1">未来战争：用大数据夺取制信息权。</li>
                        <li class="l2">2018.04.21</li>
                        <li class="l3"><p><%= record[8][1] %></p></li>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--清除浮动-->
    <div class="clear"></div>
    <!--领先中国大数据开创交易者-->
    <div class="lxzg">
        <div class="txt">
            <p>领先中国大数据交易开创者</p>
        </div>
        <div class="myinput">
            <input class="input1" type="text" name="name">
            <input type="text" name="pass" class="input2">
            <a class="mysubmit" href="#">立即注册</a>
        </div>
    </div>
    <!--合作伙伴-->
    <div class="hzhb"></div>
</div>
<div class="clear"></div>
<!--中部结束，尾部开始-->
<div class="bottom">
    <div class="liubai"></div>
    <div class="login"></div>
    <div class="wenzi">
        <div class="liubai-1"></div>
        <div class="first">
            <a href="#"><p class="p4">关于</p></a>
            <a href="#"><p class="p5">关于我们</p></a>
            <a href="#"><p class="p5">技术优势</p></a>
            <a href="#"><p class="p5">服务报价</p></a>
            <a href="#"><p class="p5">数据购买工作流程</p></a>
        </div>
        <div class="first">
            <a href="#"><p class="p4">关于</p></a>
            <a href="#"><p class="p5">关于我们</p></a>
            <a href="#"><p class="p5">技术优势</p></a>
            <a href="#"><p class="p5">服务报价</p></a>
            <a href="#"><p class="p5">数据购买工作流程</p></a>
        </div>
        <div class="first">
            <a href="#"><p class="p4">关于</p></a>
            <a href="#"><p class="p5">关于我们</p></a>
            <a href="#"><p class="p5">技术优势</p></a>
            <a href="#"><p class="p5">服务报价</p></a>
            <a href="#"><p class="p5">数据购买工作流程</p></a>
        </div>
        <div class="first1">
            <a href="#" class="ew"></a>
            <p class="tel">24小时咨询电话:88888888</p>
        </div>
    </div>
    <!--清除浮动-->
    <div class="clear"></div>
    <div class="address">
        <p>联系地址：北京市某某大街三十八号</p>
    </div>
</div>
<!--尾部结束-->
<!--JS代码-->
<script type="text/javascript" charset="gbk">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    myChart.setOption(option);
</script>
<script type="text/javascript">
    // 验证输入不为空的脚本代码
    function checkForm(form) {
        if(form.name.value == "") {
            alert("用户名不能为空!");
            form.name.focus();
            return false;
        }
        if(form.pass.value == "") {
            alert("密码不能为空!");
            form.pass.focus();
            return false;
        }
        return true;
    }
</script>

<script type="text/javascript">
    // 验证输入不为空的脚本代码
    function checkForm0(form) {
        if(form.name.value == "") {
            alert("用户名不能为空!");
            form.name.focus();
            return false;
        }
        if(form.password.value == "") {
            alert("密码不能为空!");
            form.password.focus();
            return false;
        }
        return true;
    }
</script>
</body>
</html>